package com.example.library.service;

import com.example.library.bean.model.Banner;
import com.example.library.bean.model.BookType;
import com.example.library.bean.response.Response;
import com.example.library.bean.response.SuccessResponse;
import com.example.library.dao.BannerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BannerService {

    @Autowired
    private BannerRepository bannerRepository;

    /**
     * 根据类型获取Banner
     * @param type
     * @return
     */
    public Response getAllByType(int type) {
        List<Banner> banners = bannerRepository.findAllByType(type);
        Response response = new SuccessResponse();
        response.setResult(banners);
        return response;
    }
}
